﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SwenAssignment3.Classes;

namespace SwenAssignment3.RoomAvailabilityCumBookingModule
{
    public partial class PaymentPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (rblPayment.SelectedValue == "Cash")
            {
                Panel1.Visible = false;
            }
            else
            {
                Panel1.Visible = true;
            }
        }
        List<RoomsBooking> bookingList;
        Guest g;
        protected void btnProceed_Click(object sender, EventArgs e)
        {
            //Changing view to view2
            MultiView1.ActiveViewIndex = 1;
            //Retrieve bookingList from previous page
            bookingList = Session["bookingList"] as List<RoomsBooking>;
            DataList1.DataSource = bookingList;
            DataList1.DataBind();
            //Retrieve all information from the guest
            g = Session["guest"] as Guest;
            lblGuestID.Text = g.GuestID;
            lblFName.Text = g.FirstName;
            lblLName.Text = g.LastName;
            lblContact.Text = Convert.ToString(g.PhoneNo);
            lblEmail.Text = g.Email;
            lblHomeAdd.Text = g.HomeAddress;
            lblPostal.Text = g.PostalCode;
            lblContact.Text = g.Nationality;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Invoice inv = Session["Invoice"] as Invoice;
            foreach (RoomsBooking rb in bookingList)
            {
                DRHotelDBManager.createNewBooking(rb);
            }
            DRHotelDBManager.createGuest(g);
            DRHotelDBManager.createInvoice(inv);
        }
    }
}